package com.world.rickcloudendpoint.service.net.session;

import com.world.rickcloudendpoint.common.AbstractUpdate;

/**
 * @description: 网络检查更新
 * @author: jlsong
 * @date: 2021/12/24 21:27:45
 * @version: 1.0
 */
public class TcpNetStateUpdate extends AbstractUpdate {

    private static final long serialVersionUID = 8114145039789355085L;
    public volatile TcpNetState state = TcpNetState.CONNECTED;

    @Override
    public void update() {
        updateConnect();
    }

    public void updateConnect() {

        if (state == TcpNetState.DISCONNECTING) {
            setDisconnected();
        } else if (state == TcpNetState.DISCONNECTED) {
            processDisconnect();
        }
    }

    public void processDisconnect() {
        state = TcpNetState.DESTROY;
    }

    public void setDisconnected() {
        state = TcpNetState.DISCONNECTED;
    }

    public void setDisconnecting() {
        state = TcpNetState.DISCONNECTING;
    }
}
